<template>
  <div class="page-container " v-loading="loading" v-loadingCommonStyle>
    <ex_header_spiler :title="title" />
    <ex_super_table v-bind="skuOption" :data="form.rows" size="default" :autoFlex="true">
    </ex_super_table>
  </div>
</template>

<script>

import router_params from '@/mixin/router_params';
export default {
  title: "title_standard_check_detail",
  components: {},
  mixins: [router_params],
  data() {
    return {
      loading: false,
      title: "",
      form: {},
      skuOption: {
        model: [
          {
            key: 'boxNo', label: 'label_box_code', 'min-width': 120,
            propertyFilter: true, sortable: true,
            render: (h, { row, column }) => {
              const code = row[column.property]
              if (!code) return this.$tt('data_temp_none')
              return (<text_extra_tooltip_operate
                value={code}
                data_type={column.property} data_id={row.boxId}
                extra_barcode_image={true} extra_text_align='center'
              />)
            },
          },
          {
            key: 'skuBarcode', label: 'label_sku_code', 'min-width': 100,
            propertyFilter: true, sortable: true,
            render: (h, { row, column }) => {
              const code = row[column.property]
              if (!code) return this.$tt('data_temp_none')
              return (<text_extra_tooltip_operate
                value={code}
                data_type={column.property} data_id={row.boxId}
                extra_barcode_image={true} extra_text_align='center'
              />)
            },
          },
          {
            key: 'skuName', label: 'label_sku_name', 'min-width': 100, 'show-overflow-tooltip': true,

          },
          { key: 'receivingQty', label: 'label_receiving_number', 'width': 100, sortable: true, },
          { key: 'acceptanceQty', label: 'label_acceptance_number', 'width': 100, sortable: true, },
          {
            key: 'dimension',
            label: 'label_dimension_weight', 'width': 220, render: (h, { row }) => {
              if ([row.skuWeight, row.skuLength, row.skuWidth, row.skuHeight].every(it => !it)) return this.$tt('data_temp_none')
              return (<div>

                <div>{this.$tt("label_weight") + " : "}{this.$renderText(h, this.$addUnit(this.$formatDigit(row.skuWeight, 3), "kg"))}</div>
                <div>{this.$tt("label_length") + " : "}{this.$renderText(h, this.$addUnit(this.$formatDigit(row.skuLength, 2), "cm"))}</div>
                <div>{this.$tt("label_width") + " : "}{this.$renderText(h, this.$addUnit(this.$formatDigit(row.skuWidth, 2), "cm"))}</div>
                <div>{this.$tt("label_height") + " : "}{this.$renderText(h, this.$addUnit(this.$formatDigit(row.skuHeight, 2), "cm"))}</div>
              </div>)
            }
          },
          {
            key: 'check_dimension',
            label: 'label_check_info', 'width': 220, render: (h, { row }) => {
              if ([row.checkSkuWeight, row.checkSkuLength, row.checkSkuWidth, row.checkSkuHeight].every(it => !it)) return this.$tt('data_temp_none')
              return (<div>
                <div>{this.$tt("label_weight") + " : "}{this.$renderText(h, this.$addUnit(this.$formatDigit(row.checkSkuWeight, 3), "kg"))}</div>
                <div>{this.$tt("label_length") + " : "}{this.$renderText(h, this.$addUnit(this.$formatDigit(row.checkSkuLength, 2), "cm"))}</div>
                <div>{this.$tt("label_width") + " : "}{this.$renderText(h, this.$addUnit(this.$formatDigit(row.checkSkuWidth, 2), "cm"))}</div>
                <div>{this.$tt("label_height") + " : "}{this.$renderText(h, this.$addUnit(this.$formatDigit(row.checkSkuHeight, 2), "cm"))}</div>

              </div>)
            }
          },
          {
            key: 'acceptanceUserName', label: 'label_acceptance_user', 'width': 130, 'show-overflow-tooltip': true,
            formatter: (r, c, v, i) => this.$formatNameCode(v, r.acceptanceUserCode)
          },
          { key: 'acceptanceTime', label: 'label_acceptance_date', 'min-width': 130, formatter: (r, c, v, i) => this.$dateFormat(v) },
        ]
      },
    }
  },
  computed: {
    IsPALLET() {
      return this.form.isPallet == "Y"
    },
  },
  methods: {

    init_data_default(into_params) {
      if (into_params.id) {
        this.loading = true
        this.$ajax({
          url: "/wms-api/inbound/WmsInboundOverseasAcceptanceRpc/selectDetail.json",
          method: 'post',
          data: { acceptanceId: into_params.id },
          success: (res) => {
            this.form = Object.assign({}, res.data)

          },
          complete: () => {
            this.loading = false
          }
        })
      }

      this.$emit("tagModifyLabel", {
        _key: 'label_name_code', name: this.$tt("title_standard_check_detail"),
        code: into_params.code
      })
      this.title = `${this.$tt('label_acceptance_code')}:${into_params.code} / ${this.$tt('label_inbound_code')}:${into_params.order}`
      // this.fixTabLabel()
    },


  }
}
</script>
